-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Out_channel STM tests #431
Conversation
CI summary for 2150652:
Out of 59 workflows 7 failed with 1 genuine failure and 6 ci setup issues |
I've rebased the PR on |
CI summary for 024dd85
Out of 44 workflows 5 failed with all 5 being genuine failures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A real test for Out_channel
s, where we explicitly take care of the buffering, this is very nice! Congratulations!
Do you think the STM tests are less likely to trigger such defects? |
Thanks for the review! Discussing this PR with you triggered me to look up previous counterexamples reported by the
This should have a possible sequentialization (below) which we seem to miss:
Looking at previous counterexamples also made me realize that
Our discussion also made me check my recollection regarding locking:
As such, they
Possibly, but I'm unsure.
Since #interleavings can be quite high, a corner case bug is more likely to trigger more often when it is run more. |
In 8236876 I extend the |
In the sequentialized version, the
To make sure that I understand correctly what this is doing, because I think I missed it in my first review: due to the |
This is a probable explanation indeed! 👍
Point well taken - and yes, you are right 👍 I've therefore taken a pass over the This revealed a divergence from the spec as I shared offline: val close : t -> unit
(** Close the given channel, flushing all buffered write operations. Output
functions raise a [Sys_error] exception when they are applied to a closed
output channel, except {!close} and {!flush}, which do nothing when applied
to an already closed channel. Note that {!close} may raise [Sys_error] if
the operating system signals an error when flushing or closing. *) Yet
For now, I've adjust |
We can now experimentally confirm that the latest changes can indeed find issues like that.
|
Some overdue CI summaries... For 9c63209:
Out of 44 workflows 5 failed and 1 was cancelled, all 6 due to genuine issues For 8236876:
Out of 44 workflows 5 failed with all 5 being genuine issues For 0c8fdcb:
Out of 44 workflows 24 failed with a total of 28 failures (4 workflows failed two tests) with all of them being genuine |
The PR's latest test revision is so effective at triggering the #432 regression that we should consider temporarily relaxing the test to accept the current behaviour, to avoid having to check ~20 failing workflows on each CI run... 😬 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good, thank you for the updates!
CI summary:
Out of 44 workflows 2 failed, with both being genuine issues |
CI summary for merge to
Out of 45 workflows 1 failed with a genuine issue |
The
Lin
Out_channel
test is a sore point of the test suite:Out_channel
s buffer internally, meaninglength
's result can vary.This is a bad fit for
Lin
's sequential consistency test, because we may end up finding counterexamples of different buffering (between a parallel and any interleaved sequential run) - or just spend a long time searching for one.As such, a model-based
STM
test is a better fit - and this PR offers one.The new model-based test
Out_channel
module as the existingLin
testMany things thus speak for switching to it.
On the other hand, despite its downsides the old Lin test has also managed to stress the runtime into triggering defects #412
Technically, there are a few nuggets in the test code:
Out_channel
s with suitable preconditions. As such the test can generate open-close-open-closecmd
sequences.length
's output is handled by comparing less-or-equal-to the model's lengthlength
increases by 2 for every'\n'
output (since'\n'
maps to"\r\n"
)position
does not reflect this translation thoughset_binary_mode
: it may not be the mode enabled at output-call-time that takes effect (example below). This is solved by always callingflush
beforeset_binary_mode
on MinGW/Cygwin where this matters:Closes #378 and #401